]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Split out policy creation
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 1 Nov 2017 18:21:31 +0000 (19:21 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 22 Jan 2019 21:33:46 +0000 (21:33 +0000)
The _createPolicy() method of a subclass usually depends on some
constructor parameters that need to be set before chaining up to
the parent. This works fine with Lang.Class, but will break with
ES6 classes, as "this" is only initialized after chaining up.

Prepare for this by not creating the policy in the constructor,
but when it is first accessed.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/350

js/ui/messageTray.js

index fc4e00c9d97630e2b8a02d846a2e0e3cbd9ae6f6..7ce977f47b753cfdbe5ccc93bbd00f9b15d68590 100644 (file)
@@ -701,7 +701,13 @@ var Source = new Lang.Class({
 
         this.notifications = [];
 
-        this.policy = this._createPolicy();
+        this._policy = null;
+    },
+
+    get policy() {
+        if (!this._policy)
+            this._policy = this._createPolicy();
+        return this._policy;
     },
 
     get count() {